﻿using System;
using Resn.WhuPub.BLL;
using Resn.WhuPub.DAL;
using Resn.WhuPub.DML;

namespace Resn.WhuPub.BLL
{
        /// <summary>
        /// 实现课程的属性和方法
        /// </summary>
        public class Course : Entity<CourseModel>
        {
                #region 构造函数

                /// <summary>
                /// 创建课程实例
                /// </summary>
                /// <param name="model">课程模型</param>
                public Course(CourseModel model)
                        : base(model)
                {
                }

                #endregion


                #region 属性

                #region 基本属性

                

                /// <summary>
                /// 获取课程运作Id
                /// </summary>
                /// <value>
                /// 课程运作Id
                /// </value>
                public string MajorOperationId
                {
                        get
                        {
                                return Model.MajorOperationId;
                        }
                }

                /// <summary>
                /// 获取或设置课程教师标识
                /// </summary>
                /// <value>
                /// 教师标识
                /// </value>
                public string ContactId
                {
                        get
                        {
                                return Model.ContactId;
                        }
                        set
                        {
                                Model.ContactId = value;
                        }
                }

                /// <summary>
                /// 获取或设置课程名称
                /// </summary>
                /// <value>
                /// 课程名称
                /// </value>
                public string Name
                {
                        get
                        {
                                return Model.Name;
                        }
                        set
                        {
                                Model.Name = value;
                        }
                }

                /// <summary>
                /// 获取或设置课程是否必修
                /// </summary>
                /// <value>
                /// 课程是否必修
                /// </value>
                public bool IsCompulsory
                {
                        get
                        {
                                return Model.IsCompulsory;
                        }
                        set
                        {
                                Model.IsCompulsory = value;
                        }
                }

                /// <summary>
                /// 获取或设置课程学生人数
                /// </summary>
                /// <value>
                /// 学生人数
                /// </value>
                public int StudentsAmount
                {
                        get
                        {
                                return Model.StudentsAmount;
                        }
                        set
                        {
                                Model.StudentsAmount = value;
                        }
                }

                #endregion 基本属性

                #endregion 属性

                #region 方法

                /// <summary>
                /// 获取指定标识的对象
                /// </summary>
                /// <param name="id">标识</param>
                /// <returns></returns>
                public static Course Select(string id)
                {
                        return Select<Course>(id);
                }

                /// <summary>
                /// 创建课本
                /// </summary>
                /// <param name="bookId">书籍标识</param>
                /// <param name="useAmount">使用数量</param>
                /// <returns>
                /// 创建的课本对象
                /// </returns>
                public CourseBook CreateCourseBook(string bookId, int useAmount)
                {
                        var model = new CourseBookModel
                                {
                                        Id = Guid.NewGuid().ToString(),
                                        CourseId = Id,
                                        BookId = bookId,
                                        UseAmount = useAmount
                                };
                        return  new CourseBook(model);
                }

                

                #endregion

        }
}